package com.ruicar.afs.cloud.afscase.autoaudit.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.afscase.autoaudit.entity.ApproveRiskTipsRule;
import com.ruicar.afs.cloud.afscase.autoaudit.mapper.ApproveRiskTipsRuleMapper;
import com.ruicar.afs.cloud.afscase.autoaudit.service.ApproveRiskTipsRuleService;
import com.ruicar.afs.cloud.afscase.infomanagement.entity.CaseBaseInfo;
import com.ruicar.afs.cloud.afscase.infomanagement.service.*;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinCostDetails;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.CostTypeEnum;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class ApproveRiskTipsRuleServiceImpl extends ServiceImpl<ApproveRiskTipsRuleMapper, ApproveRiskTipsRule> implements ApproveRiskTipsRuleService {

    private CaseBaseInfoService caseBaseInfoService;

    private CaseContractInfoService caseContractInfoService;

    private CaseCarInfoService caseCarInfoService;

    private CaseCostInfoService caseCostInfoService;

    private CaseChannelInfoService caseChannelInfoService;

    public JSONObject getApproveRiskTipsParam(String applyNo){
        JSONObject json=new JSONObject();
        CaseBaseInfo caseBaseInfo = caseBaseInfoService.getOne(Wrappers.<CaseBaseInfo>query().lambda().eq(CaseBaseInfo::getApplyNo,applyNo));
        FinCostDetails caseCostInfo = caseCostInfoService.getOne(Wrappers.<FinCostDetails>query().lambda()
                .eq(FinCostDetails::getApplyNo,caseBaseInfo.getApplyNo())
                .eq(FinCostDetails::getCostType,CostTypeEnum.CARAMT.getCode()));
        json.put("businessType",caseBaseInfo.getBusinessType());
        json.put("carNature",caseBaseInfo.getCarNature());
        json.put("carType",caseBaseInfo.getCarType());
        json.put("carLoanAmount",caseCostInfo.getLoanAmt().toString());
        return json;
    }
}
